import requests
import logging

# 日志配置
logging.basicConfig(
    level=logging.INFO,
    format='[%(asctime)s] [%(levelname)s] - %(message)s',
    datefmt='%Y-%m-%d %H:%M:%S'
)

def account_login():

    # 百世OA原接口
    # http://oa.800best.com/best/api

    # 新测试接口
    url = "https://oa.800best.icu/best/oa"

    headers = {
        "Cache-Control": "max-age=0",
        "Upgrade-Insecure-Requests": "1",
        "Origin": "https://oa.800best.icu",
        "Content-Type": "application/x-www-form-urlencoded"
    }
    # 测试完请删除
    data = {"username": "zhongnian@800best.com", "password": "Ace800best"}

    try:
        with requests.Session() as session:
            req = session.post(url, headers=headers, data=data)
            req.raise_for_status()  
            logging.info("请求成功，响应内容：%s", req.content)
    except requests.RequestException as e:
        logging.error("请求异常：%s", e)


def query_express(tracking_number, carrier="BEST", retries=3):
    """
    查询快递物流信息
    :param tracking_number: 快递单号
    :param carrier: 快递公司代码 (如: BEST, SF, ZTO)
    :param retries: 重试次数
    :return: JSON 格式的物流信息
    """
    params = {
        "tracking_number": tracking_number,
        "carrier": carrier,
        "timestamp": datetime.now().strftime("%Y%m%d%H%M%S")
    }
